import { build } from 'esbuild';

build({
  entryPoints: ['src/main.ts'],
  bundle: true,
  format: 'iife',
  outfile: 'dist/bundle.js',
  watch: {
    onRebuild (error) {
      if (error) console.error('Watch build failed:', error);
      else console.log('Watch build succeeded:', new Date().toLocaleTimeString());
    },
  },
})
  .then(() => console.log('Watching for changes...'))
  .catch(() => process.exit(1));
